import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import '../util.dart';

class AppButton extends StatelessWidget {
  const AppButton({ Key? key,
    this.content,
    this.onTap,
    this.height = 45,
    this.style,
    this.child,
    this.radius = 8,
    this.lightTheme = false,
    this.outline = false,
    this.outlineColor,
    this.margin,
    this.boxShadow,
    this.gradientColors,
    this.color
  }) : super(key: key);

  final double radius;
  final String? content;
  final Function? onTap;
  final double height;
  final TextStyle? style;
  final bool lightTheme;
  final Widget? child;
  final bool? outline;
  final Color? outlineColor;
  final EdgeInsets? margin;
  final List<BoxShadow>? boxShadow;
  final List<Color>? gradientColors;
  final Color? color;

  @override
  Widget build(BuildContext context) {
    return Container(
      height: height.h,
      margin: margin,
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(radius),
        boxShadow: boxShadow
      ),
      child: ClipRRect(
        borderRadius: BorderRadius.circular(radius),
        child: Material(
          borderRadius: BorderRadius.circular(radius),
          child: Ink(
            decoration: BoxDecoration(
              border: outline == true
                  ? Border.all(color: outlineColor ?? const Color(0xFF5A89FF)) : null,
              borderRadius: BorderRadius.circular(radius),
              gradient: color == null ? LinearGradient(
                  begin: Alignment.centerLeft,
                  end: Alignment.centerRight,
                  colors: gradientColors ?? [Colors.blue, Colors.blue]
              ) : null,
              color: color
            ),
            child: InkWell(
              splashColor: Colors.white24,
              onTap: (){
                onTap?.call();
              },
              child: Center(child: Text(content!, style:
              style ?? const TextStyle(fontSize: 14, color: Colors.white, fontWeight: FontWeight.bold))),
            ),
          ),
        ),
      ),
    );
  }

}

